package dominion.kingdom;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import dominion.Action;
import dominion.Card;
import dominion.CardTypes;
import dominion.Player;

public abstract class AbstractAttackAction implements Action {

	static final Logger LOG = LoggerFactory
			.getLogger(AbstractAttackAction.class);

	protected boolean hasMoat(Player p) {
		p.addAttackedCount();
		boolean result = has(p, CardTypes.Moat);
		if (result) {
			LOG.info("{} has Moat !!", p.name());
			p.addProtectedCount();
		}
		return result;
	}

	protected boolean has(Player p, CardTypes ct) {
		for (Card c : p.hand()) {
			if (ct.equals(c.getType())) {
				return true;
			}
		}
		return false;
	}

	@Override
	public String toString() {
		return getType().name();
	}

}
